load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

location_f="/Users/ivana/WORK_BSC/AS/files/"

fw    = addfile(location_f + "seaicearea_lowice_members.nc", "r")
fc    = addfile(location_f + "seaicearea_ctrl_members.nc", "r")

print(fw)
print(fc)

;*******************************************;
;Read in variables
;*******************************************

icesumc = new((/10,12/), double)
icesumw = new((/10,12/), double)

icesumc(0,:) = fc->SIA_1_A
icesumc(1,:) = fc->SIA_2_A
icesumc(2,:) = fc->SIA_3_A
icesumc(3,:) = fc->SIA_4_A
icesumc(4,:) = fc->SIA_5_A
icesumc(5,:) = fc->SIA_6_A
icesumc(6,:) = fc->SIA_7_A
icesumc(7,:) = fc->SIA_8_A
icesumc(8,:) = fc->SIA_9_A
icesumc(9,:) = fc->SIA_10_A


icesumw(0,:) = fw->SIA_1_A
icesumw(1,:) = fw->SIA_2_A
icesumw(2,:) = fw->SIA_3_A
icesumw(3,:) = fw->SIA_4_A
icesumw(4,:) = fw->SIA_5_A
icesumw(5,:) = fw->SIA_6_A
icesumw(6,:) = fw->SIA_7_A
icesumw(7,:) = fw->SIA_8_A
icesumw(8,:) = fw->SIA_9_A
icesumw(9,:) = fw->SIA_10_A

icesumc = icesumc*10^(-12)

icesumw = icesumw*10^(-12)

month = ispan(0,11,1)*1.0
;****************************************
; Create plot
;****************************************
wks = gsn_open_wks("pdf","icearea_monthly_ipsl")

   plot    = new (1,"graphic")
  
   res                      = True          ; individual plot
   res@gsnDraw              = False
   res@gsnFrame             = False
   res@xyLineThicknessF     = 2.0
   res@xyMonoLineColor         =True
   res@xyLineColor         = "black"

   res@tmXBMode        = "Explicit"	 	
   res@tmXBValues      = month  

   res@tmXBLabels      = (/"J","F","M","A","M","J"\
              ,"J","A","S","O","N","D"/) 

   res@xyDashPattern        = 0                  ; Make curves all solid

   res@vpHeightF= 0.4                    ; change aspect ratio of plot
   res@vpWidthF = 0.8 
 
   res@trXMinF  =  0
   res@trXMaxF  = 11
   res@trYMinF=0
   res@trYMaxF=16
   
   res@tiXAxisFontHeightF = 0.010
   res@tiYAxisFontHeightF = 0.015

   res@gsnLeftString = ""
   res@tiXAxisString = "" 
   res@tiYAxisString = ""

   icesumc!0 = "ncl_join"
   icesumc!1= "time"
   icesumc&time= month

   icesumw!0 = "ncl_join"
   icesumw!1= "time"
   icesumc&time= month

   
   plot(0)  = gsn_csm_xy (wks,month,icesumc,res) 
   res@xyLineColor         = "cyan3" 
   plot1  = gsn_csm_xy (wks,month,icesumw,res)
 
   overlay(plot(0), plot1)

;***** make panel ***** 
   

   resP                     = True          ; panel resources
   resP@gsnMaximize         = True
   
   resP@txFontHeightF = 0.015 
;   resP@txString            = "NH warming only" 
;  resP@txString            = "SH warming only"
   gsn_panel(wks,plot,(/2,1/),resP)
